import QtQuick 2.0
import QtQuick.Controls 2.5
Rectangle{
    id:qml_syntax_root
    width: parent.width
    height: parent.height
    color: "#D8D8D8"
    Keys.enabled: true;
    Image {
        id: qml_syntax_rocket
        x:(parent.width-width)/2
        y:40
        source: "images/rocket.png"
    }
    Text {
        id:qml_syntax_rocket_label
        y:qml_syntax_rocket.y+qml_syntax_rocket.height+20
        width: 300
        height: 400
        horizontalAlignment: Text.AlignHCenter
        text: qsTr("Space pressed:"+spacePresses+" times")
        //自定义属性
        property int times: 24
        property int spacePresses: 0
        //属性别名
        property alias anotherTimes: qml_syntax_rocket_label.times

        font.family: "Ubuntu"
        font.pixelSize: anotherTimes

        onTextChanged: console.log("text changed to:",text)

        onHeightChanged: console.log("height:",height)
        focus: true
        Keys.enabled: true;
        Keys.onPressed: {
            console.log("space")
            switch(event.key)
            {
             case Qt.Key_Enter:
                 increment()
                 break;
             case Key_Return:
                 increment()
                 break;
           }



        }
        Keys.onEscapePressed: {
            qml_syntax_rocket_label.text=''
        }

        //自定义函数
        function increment(){
            spacePresses=spacePresses+1
        }
    }
}
